package com.ioudi.digu.service.impl;

import java.util.Map;

import com.ioudi.digu.service.support.ListResult;

public class AbstractFriendshipService extends AbstractService
{
	public boolean addFriend(String user,String friend, String groupName)
	{
		if(user.equals(friend))
		{
			return true;
		}
		Class[] methodParams = {String.class, String.class, String.class};
		Object result = operationAtDatasource(user, "addFriendInternal", methodParams, user, friend, groupName);
		if(result != null )
		{
			return (Boolean)result;
		}
		return false;
	}
	
	public boolean addFriendInternal(String user,String friend, String groupName)
	{
		return false;
	}
	
	
	public byte getFriendShip(String userA, String userB)
	{
		if(userA.equals(userB))
		{
			return 0x11;
		}
		byte friendship = 0;
		Class[] methodParams = {String.class, String.class};
		Object result = operationAtDatasource(userA, "existFriend", methodParams, userA, userB);
		if(result != null && (Boolean)result)
		{
			friendship = 0x10;
		}
		result = operationAtDatasource(userB, "existFriend", methodParams, userB, userA);
		if(result != null && (Boolean)result)
		{
			friendship |= 0x01;
		}
		return friendship;
	}
	
	public boolean existFriend(String user, String friend)
	{
		return false;
	}
	
	public boolean hasFriend(String user, String friend)
	{
		if(user.equals(friend))
		{
			return true;
		}
		Class[] methodParams = {String.class, String.class};
		Object result = operationAtDatasource(user, "hasFriendInternal", methodParams, user, friend);
		if(result != null )
		{
			return (Boolean)result;
		}
		return false;
	}
	
	public boolean hasFriendInternal(String user, String friend)
	{
		return false;
	}
	
	
	public boolean hasFollower(String user, String friend)
	{
		if(user.equals(friend))
		{
			return true;
		}
		Class[] methodParams = {String.class, String.class};
		Object result = operationAtDatasource(user, "hasFollowerInternal", methodParams, user, friend);
		if(result != null )
		{
			return (Boolean)result;
		}
		return false;
	}
	
	public boolean hasFollowerInternal(String user, String friend)
	{
		return false;
	}
	
	public ListResult getFollowers(String user, int index, int maxCount, Map<String, Object> condition)
	{
		Class[] methodParams = {String.class, int.class, int.class, Map.class};
		Object result = operationAtDatasource(user, "hasFollowerInternal", methodParams, user, index,
				maxCount, condition);
		if(result != null )
		{
			return (ListResult)result;
		}
		return null;
	}
	
	public ListResult getFollowersInternal(String user, int index, int maxCount, Map<String, Object> condition)
	{
		return null;
	}
	
	public boolean deleteFriend(String user, String friend)
	{
		Class[] methodParams = {String.class, String.class};
		Object result = operationAtDatasource(user, "deleteFriendInternal", methodParams, user, friend);
		if(result != null )
		{
			return (Boolean)result;
		}
		return false;
	}
	
	public boolean deleteFriendInternal(String user, String friend)
	{
		return false;
	}
	
	public boolean deleteFollowship(String user, String follower)
	{
		Class[] methodParams = {String.class, String.class};
		Object result = operationAtDatasource(user, "deleteFollowshipInternal", methodParams, user, follower);
		if(result != null )
		{
			return (Boolean)result;
		}
		return false;
	}
	
	public boolean deleteFollowshipInternal(String user, String follower)
	{
		return false;
	}
    
	
}
